// The Vue build version to load with the `import` command
// (runtime-only or standalone) has been set in webpack.base.conf with an alias.
import Vue from 'vue'
import App from './App'
import router from './router'

Vue.config.productionTip = false
router.beforeEach((to, from, next) => {
    const Token = localStorage.getItem('Token')
    if (Token != 'null' && Token != null) {
        Vue.http.headers.common['Authorization'] = 'Bearer ' + Token; // 全局设定header的token验证，注意Bearer后有个空格
        console.log("Token-"+Vue.http.headers.common['Authorization'])
        next()
    } else if(Token==null){
        next()
    }
})

/* eslint-disable no-new */
new Vue({
    el: '#app',
    router,
    template: '<App/>',
    components: {App}
})
